package com.kkshop.gwt.widget.wizard.impl;

import com.kkshop.gwt.widget.wizard.Wizard;
import com.kkshop.gwt.widget.wizard.WizardPage;
import com.kkshop.gwt.widget.wizard.WizardWidget;

public abstract class AbstractWizardWidget implements WizardWidget {

    protected WizardPage currentPage;

    protected Wizard wizard;

    public AbstractWizardWidget(Wizard wizard) {
        this.wizard = wizard;
        this.wizard.setWizardWidget(this);
    }

    /**
     * Can be called by subclasses right before doing anything in
     * {@link WizardWidget#createWidget()} - it will basically initialize .. and
     * also call {@link Wizard#addPages()}
     * 
     */
    protected void preCreateWidget() {
        wizard.addPages();
    }

    public WizardPage getCurrentPage() {
        return currentPage;
    }

    public Wizard getWizard() {
        return wizard;
    }

    public void handleCancelClick() {
        wizard.cancel();
    }

    public void handleFinishClick() {
        wizard.finish();
    }

}
